import 'package:state_management_flutter_bloc/models/api_models.dart';
import 'package:state_management_flutter_bloc/services/player_api_provider.dart';

class PlayerRepository{
  PlayerApiProvider _playerApiProvider = PlayerApiProvider();

  Future<ApiResult> fetchPlayersByCountry(String countryId,{int page = 1})
  =>_playerApiProvider.fetchPlayersByCountry(countryId,page: page);

  Future<ApiResult> fetchPlayersByName(String name,{int page = 1})
  =>_playerApiProvider.fetchPlayersByName(name,page: page);

  Future<ApiResult> fetchPlayersAdvanceSearch(Map<String,String> nations,Map<String,String> leagues,List<String> positions,{int page = 1}){
    String strNations  =nations.isEmpty?null: nations.values.join(',');
    String strLeagues =leagues.isEmpty?null: leagues.values.join(",");
    return _playerApiProvider.fetchPlayersAdvanceSearch(strNations,strLeagues,positions.isEmpty?null:positions.join(','),page: page);
  }
}